﻿@using King.Box.Utils.Global;
@using King.Box.Models.View.Sys;
@{
    var CurrentUser = Session[GlobalConst.Session_User] as Sys_UserData;
}

<nav class="navbar-default navbar-static-side" role="navigation">
    <div class="nav-close">
        <i class="fa fa-times-circle"></i>
    </div>
    <div class="sidebar-collapse">
        <ul class="nav" id="side-menu">
            <li class="nav-header">
                <div class="dropdown profile-element">
                    <span><img alt="image" class="img-circle" src="@Url.Content(string.IsNullOrEmpty(CurrentUser.HeaderImg) ? "~/Content/Img/profile_small.jpg" : CurrentUser.HeaderImg)" /></span>
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                        <span class="clear">
                            <span class="block m-t-xs"><strong class="font-bold">@CurrentUser.Nick</strong></span>
                            <span class="text-muted text-xs block">@CurrentUser.MainRole.RoleName<b class="caret"></b></span>
                        </span>
                    </a>
                    <ul class="dropdown-menu animated fadeInRight m-t-xs">
                        <li>
                            <a class="J_menuItem" href="profile.html">个人资料</a>
                        </li>
                        <li>
                            <a class="J_menuItem" href="contacts.html">联系我们</a>
                        </li>
                        <li class="divider"></li>
                        <li>
                            <a href="@Url.Action("LogOut","Home")">安全退出</a>
                        </li>
                    </ul>
                </div>
                <div class="logo-element">
                    King Box
                </div>
            </li>
            @foreach (var menu in CurrentUser.Menus)
            {
                <li>
                    <a href="@(string.IsNullOrEmpty(menu.Url)?"#":menu.Url)">
                        <i class="@menu.Icon"></i>
                        <span class="nav-label">@menu.Name</span>
                        <span class="fa arrow"></span>
                    </a>

                    @if (menu.HasSubMenu)
                    {
                        <ul class="nav nav-second-level">

                            @foreach (var level2Menu in menu.SubMenus)
                            {
                                if (level2Menu.HasSubMenu)
                                {
                                    <a href="@(string.IsNullOrEmpty(level2Menu.Url)?"#":level2Menu.Url)">
                                        <i class="@level2Menu.Icon"></i>
                                        @level2Menu.Name<span class="fa arrow"></span>
                                    </a>
                                    <ul class="nav nav-third-level">
                                        @foreach (var level3Menun in level2Menu.SubMenus)
                                        {
                                            <li>
                                                <a class="J_menuItem" href="@level3Menun.Url">
                                                    <i class="@level3Menun.Icon"></i>
                                                    @level3Menun.Name
                                                </a>
                                            </li>
                                        }
                                    </ul>
                                }
                                else
                                {
                                    <li>
                                        <a class="J_menuItem" href="@(string.IsNullOrEmpty(level2Menu.Url)?"#":level2Menu.Url)">
                                            <i class="@level2Menu.Icon"></i>
                                            @level2Menu.Name
                                        </a>
                                    </li>
                                }
                            }
                        </ul>
                    }
                </li>
            }
        </ul>
    </div>
</nav>
